//
//  UILabel+Cate.m
//  LookCoupons
//
//  Created by 明明方 on 2017/9/8.
//  Copyright © 2017年 明明方. All rights reserved.
//

#import "UILabel+Cate.h"

@implementation UILabel (Cate)

+(instancetype)labelWithFrame:(CGRect)frame textColor:(UIColor *)color fontSize:(CGFloat)font TextAlignment:(NSTextAlignment)textAlignment placeHolderText:(NSString *)text{
    UILabel * label = [[UILabel alloc] initWithFrame:frame];
    label.text = text;
    label.textColor = color;
    label.backgroundColor = [UIColor clearColor];
    label.font = [UIFont systemFontOfSize:font];
    label.textAlignment = textAlignment;
    return label;
    
    /*
     _timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(MARGIN, 0, SCREEN_WIDTH - MARGIN*2, autoX(60))];
     _titleLabel.text = @"3-14 12:30";
     _titleLabel.textColor = TextGRAY_COLOR;
     _titleLabel.font = [UIFont systemFontOfSize:13];
     */
}

- (CGSize)contentSize
{
    NSMutableParagraphStyle * paragraphStyle = [[NSMutableParagraphStyle alloc] init];
    paragraphStyle.lineBreakMode             = NSLineBreakByCharWrapping;
    paragraphStyle.alignment                 = self.textAlignment;
    NSDictionary * attributes                = @{NSFontAttributeName : self.font,
                                                 NSParagraphStyleAttributeName : paragraphStyle};
    return [self.text boundingRectWithSize:CGSizeMake([UIScreen mainScreen].bounds.size.width - 50, 1000)
                                   options:NSStringDrawingUsesLineFragmentOrigin
                                attributes:attributes
                                   context:nil].size;
}

@end
